import axios from 'axios';
import { parseJsonData } from './jsonParser.js';

export function getCameraInformationByDate(cameraId,Date){

        var host = window.location.hostname;

        return new Promise((resolve, reject) => {
        var config = {
        method: 'get',
        url: 'http://'+host+':8080/CameraInformation/getInformationByDate?cameraid=' + cameraId + '&date=' + Date,
        headers: { }
        };

        axios(config)
            .then(function (response) {
                try {
                    const parsedData = parseJsonData(response.data);
                    resolve(parsedData);
                } catch (error) {
                    reject(error);
                }
            })
            .catch(function (error) {
                reject(error);
            });
    });

}